home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Simple Slideshow / TIFF code folder / Read Me First next >
Encoding:
Text File  |  1994-10-17  |  2.5 KB  |  109 lines  |  [TEXT/KAHL]

  1. Graham.
  2.     Here is sample code on how to use the TIFF code.  It's fairly straight forward.  You
  3. may need to change some things to suit your own application frame work.  This code opens NeXT TIFF files
  4. as well as TIFF 5.0 (but not TIFF 6.0).
  5.  
  6.  
  7.     First to open the file:
  8.         display_image_GW = ReadTIFF( &fsp, ( **recHdl ).volName, TRUE, &imageInfo, &err, &r );
  9.         
  10.         if ( display_image_GW == NIL )
  11.         {
  12.             rBounds = r;
  13.         }
  14.         else
  15.         {
  16.             rBounds = display_image_GW->portRect;
  17.         }
  18.  
  19.         display_window = MakeDisplayWindow( &rBounds, fsp.name );    // or what ever you do for your display windows
  20.         
  21.         w_palette = GetPalette( display_window );    // save the old palette and restore it when you dispose of the window
  22.         
  23.         InitPalette( );
  24.         
  25.     Now for updating:
  26.  
  27. /************************************************************************
  28. ************************************************************************/
  29.  
  30. void UpdateDisplayWindow( WindowPtr w, Rect *r )
  31. {
  32.     Point            origin;
  33.     MyData            **dataH;
  34.     Rect            copyRect;
  35.     GrafPtr            oldPort;
  36.     RGBColor        oldFore, oldBack;
  37.     OSType            type;
  38.     
  39.     
  40.     if ( w == NIL )
  41.     {
  42.         return;
  43.     }
  44.         
  45.     dataH = ( MyData ** ) GetWRefCon( w );
  46.     type = ( **dataH ).fileType;
  47.     
  48.     origin.h = GetCtlValue( of your horizontal scrollbar );
  49.     origin.v = GetCtlValue( of your vertical scrollbar );
  50.  
  51.     copyRect = *r;
  52.     OffsetRect( ©Rect, origin.h, origin.v );
  53.  
  54.     GetForeColor( &oldFore );
  55.     GetBackColor( &oldBack );
  56.     
  57.     GetPort( &oldPort );
  58.     SetPort( w );
  59.  
  60.     ForeColor( blackColor );
  61.     BackColor( whiteColor );
  62.             
  63.     LockPixels( display_image_GW->portPixMap );
  64.     
  65.     if ( type == 'TIFF' )
  66.      {
  67.          if ( display_image_GW )
  68.          {
  69.             CopyBits( ( BitMap * )  &display_image_GW->portPixMap, ( BitMap * ) &w->portBits,
  70.                     ©Rect, r, ( *TIFF_Rec_Hdl)->dither ? 64 : srcCopy, NIL );
  71.         }
  72.         else
  73.         if ( ( *TIFF_Rec_Hdl )->ref != -1 )
  74.         {
  75.             DrawTIFF( ( *TIFF_Rec_Hdl )->ref, ( *TIFF_Rec_Hdl )->ti, copyRect, *r, ( *TIFF_Rec_Hdl )->dither );
  76.         }
  77.      }
  78.  
  79.     UnlockPixels( display_image_GW->portPixMap );
  80.     
  81.      SetPort( oldPort );
  82.      
  83.      RGBForeColor( &oldFore );
  84.      RGBBackColor( &oldBack );
  85. }
  86.  
  87.  
  88.         For scrolling:
  89.         
  90.         CalcDrawingRect( theWindow, &userContent );            // this is the area of the window less the scrollbars
  91.     
  92.         update = NewRgn( );
  93.     
  94.         ScrollRect( &userContent, hAmt, vAmt, update );        // hAmt/vAmt is the scroll value
  95.     
  96.         if ( update != NIL )
  97.         {
  98.             userContent = ( *update )->rgnBBox;
  99.             DisposeRgn( update );
  100.         }
  101.     
  102.         UpdateDisplayWindow( theWindow, &userContent );
  103.         
  104.         
  105.     Good luck!!!!  Any problems just send a message (I answer slowly or ( 204 ) 885 • 4519, I answer quickly
  106.     
  107. Regards,
  108.  
  109. James